﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using VoiceAI;

namespace Xiaowei.Themes
{
    public class ListDataTemplateSelector: DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is IResponseData responseData)
            {
                switch (responseData.ResponseType)
                {
                    case ResponseType.Weather:
                        return App.Current.Resources["WeatherDataTemplate"] as DataTemplate;
                    case ResponseType.SaleHelp:
                        return App.Current.Resources["SaleHelpMessageDataTemplate"] as DataTemplate;
                    case ResponseType.PlayControl:
                        return App.Current.Resources["PlayControlDataTemplate"] as DataTemplate;
                    case ResponseType.Alarm:
                        if (responseData.DataContext != null)
                        {
                            return App.Current.Resources["AlarmDataTemplate"] as DataTemplate;
                        }
                        else
                        {
                            return App.Current.Resources["ResponseDataTemplate"] as DataTemplate;
                        }
                    default:
                        return App.Current.Resources["ResponseDataTemplate"] as DataTemplate;
                }
            }
            else
            {
                return base.SelectTemplate(item, container);
            }
            
        }
    }
}
